package dao;

import entity.Clazz;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;
import untils.DruidUtil;

import java.sql.SQLException;

/**
 * @Author:SA
 * @DATA:DATA
 */


public class ClassDaoImpl implements ClassDao{
    @Override
    public Clazz selectByNname(String classname) {
        QueryRunner queryRunner = new QueryRunner(DruidUtil.getDataSource());
        String sql ="select id,classname from class where classname=?";
        try {
            Clazz clazz = queryRunner.query(sql, new BeanHandler<>(Clazz.class), classname);
            return clazz;
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }


        return null;
    }
}
